
from table import *

class user:
	def __init__(self):
		self.uid = -1
		self.name = ""
		self.sex = 'm'
		self.pic = ''
		self.table = None

	def _setInfo(self, uid, name, sex, pic):
		self.uid = uid
		self.name = name
		self.sex = sex
		self.pic = pic

	def isInTable(self):
		if not self.table :
			return False
		return True

	def userLogin(self, tid):
		if self.isInTable():
			print "warn user in table"
			return 
		table = tables[tid]
		ret = table.login(self)
		if ret < 0:
			print "login error %d" % ret
		self.table = table

	def userLogout(self):
		if( self.isInTable() ):
			self.table.logout(self)
		self.table = ""

	def userSit(self, seatid, sitMoney):
		if seatid < 0 or seatid > 8:
			return -1
		self.table.sit(self, seatid, sitMoney);

	def userStand(self):
		if not self.isInTable():
			return -1
		ret = self.table.stand(self);
		return ret

	'''
	status: 1:look,2:chip,3:flod
	'''
	def userChip(self, chipMoney, status = 1):
		if chipMoney < 0:
			return -1
		self.table.chip(chipMoney, status)
		return 0

	def debug_print(self):
		pass
